Ext.define('RDB.view.wizard.WizardWindow', {
    requires: [
	'RDB.view.wizard.WizardDialogPanel',
	'Ext.ux.CheckColumn'
    ],
    extend: 'Ext.window.Window',
    title: 'Wizard',
    height: 350,
    width: 550,
    autoShow: true,
    resizable: false,
    border: 0,
    xtype: 'wizardwindow',
    items:[{
	xtype: 'panel',
	height: '100%',//239,
	layout: 'card',
	name: 'wizardlayout',
	items: [{
	    xtype: 'wizardpanel',
	    itemId: 'wizardtype',
	    wizardConfig: {
		nextLayout: 'wizardimport',
		nextButton: {
		    disabled: false,
		},
	    },
	    tpanel:{
		html: '<h1>Please, select an option:</h1>',
	    },
	    bpanel: {
		xtype: 'form',
		name: 'wizardtype',
		items:[{
		    xtype: 'radio',
		    boxLabel: 'Update Dispatch Date/Note',
		    inputValue: 'update1',
		    checked: true,
		    name: 'wizardtype',
		},{
		    xtype: 'label',
		    html: '<a href="/share/rdb/template/template.xls">' +
			'Download template</a>'
		}],
	    },
	},{
	    xtype: 'wizardpanel',
	    itemId: 'wizardimport',
	    wizardConfig: {
		nextButton: {
		    disabled: true,
		},
		backButton: {
		    disabled: false,
		},
		backLayout: 'wizardtype',
		nextLayout: 'wizardprocess',
	    },
	    tpanel: {
		html: '<h1>Please, select a file to start importing.</h1>',
	    },
	    bpanel: {
		items: [{
		    xtype: 'form',
		    name: 'formupload',
		    height: '100%',
		    layout: 'anchor',
		    border: 0,
		    items: [{
			xtype: 'fileuploadfield',
			fieldLabel: 'file:',
			anchor: '100%',
			name: 'fileupload',
		    }]
		}],
	    },
/*	},{
	    xtype: 'wizardpanel',
	    itemId: 'wizardexport',
	    wizardConfig: {
		nextButton: {
		    disabled: false,
		},
		backButton: {
		    disabled: false,
		},
		backLayout: 'wizardtype',
		nextLayout: 'wizardprocess',
	    },
	    tpanel: {
		html: '<h1>Выберите параметры экспорта:</h1>',
	    },
	    bpanel: {
		xtype: 'form',
		name: 'wizardexport',
		items:[{
		    xtype: 'radio',
		    boxLabel: 'Использовать параметры текущего поиска',
		    checked: true,
		    name: 'querytype',
		},{
		    xtype: 'radio',
		    boxLabel: 'Задать новые параметры для фильтра',
		    inputValue: 'searchstart',
		    name: 'querytype',
		},{
		    xtype: 'checkbox',
		    boxLabel: 'Включить информацию для последующего импорта',
		    name: 'enableimport',
		},{
		    xtype: 'radio',
		    boxLabel: 'Экспорт на основе шаблона',
		    name: 'querytype',
		}],
	    },
*/	},{
	    xtype: 'wizardpanel',
	    itemId: 'wizardprocess',
	    wizardConfig: {
		nextButton: {
		    disabled: true,
		},
		backButton: {
		    disabled: true,
		},
	    },
	    tpanel: {
		html: '<h1>Please wait a moment, there is a processing...</h1>',
	    },
	    bpanel: {
		xtype: 'panel',
		items:[{
		    xtype: 'panel',
		    layout: 'hbox',
		    border: 0,
		    items: [{
			xtype: 'image',
			src: '/share/rdb/img/process2.gif',
		    },{
			xtype: 'label',
			padding: 5,
			flex: 1,
			text: 'processing...',
		    }]
		}],
	    },
	},{
	    xtype: 'wizardpanel',
	    itemId: 'wizarderror',
	    wizardConfig: {
		nextButton: {
		    disabled: true,
		},
		backButton: {
		    disabled: true,
		},
	    },
	    tpanel: {
		html: '<h1>Oops! An error has occurred!</h1>',
	    },
	    bpanel:{
		items:[{
		    xtype: 'label',
		    name: 'errormessage',
		}]
	    },
	},{
	    xtype: 'wizardpanel',
	    itemId: 'wizardtables',
	    wizardConfig: {
		nextButton: {
		    disabled: false,
		},
		backButton: {
		    disabled: true,
		},
		backLayout: 'wizardtype',
		nextLayout: 'wizardprocess',
	    },
	    tpanel: {
		html: '<h1>Prepared data for import!</h1>'
	    },
	    bpanel: {
		items: [{
		    xtype: 'grid',
		    height: 200,
		    width: 500,
		    store: 'ImportStore',
		    viewConfig: {
			stripeRows: false,
			getRowClass: function(record) {
			    console.log(record);
			    return record.get('error') == 0 ? 'no-error' : 'yes-error';
			}
		    },
		    columns: [{
			xtype: 'rownumberer',
			text: '#',
			width: 50
		    },{
			text: 'Customer *',
			dataIndex: 'customer',
			width: 70
		    },{
			text: "Model *",
			dataIndex: "model",
			width: 70
		    },{
			text: 'Серийный номер*',
			dataIndex: 'sn'
		    },{
			text: 'Инвентарный номер',
			dataIndex: 'inv'
		    },{
			text: 'Dispatch Date',
			dataIndex: 'ddate',
			renderer: Ext.util.Format.dateRenderer('d.m.Y'),
			width: 70
		    },{
			text: 'Dispatch Note *',
			dataIndex: 'dnote',
			width: 70
		    },{
			text: 'Error',
			dataIndex: 'error_message',
			width: 600
		    },{
			text: 'Error Code',
			dataIndex: 'error',
			hidden: true
		    },{
			text: 'Error Exc',
			dataIndex: 'original_exc',
			hidden: true
		    }],
		}],
	    },
/*	},{
	    xtype: 'wizardpanel',
	    itemId: 'wizardshablone',
	    wizardConfig: {
		nextButton: {
		    disabled: false,
		},
		backButton: {
		    disabled: false,
		},
		backLayout: 'wizardexport',
		nextLayout: 'wizardprocess',
	    },
	    tpanel: {
		html: '<h1>Данные для экспорта!</h1>'
	    },
	    bpanel: {
		items: [{
		    xtype: 'panel',
		    border: 0,
		    items: [{
			xtype: 'combo',
			fieldLabel: 'Шаблон',
			displayField: 'filename',
			store: 'TemplateStore',
			name: 'current_template'
		    }],
		},{
		    xtype: 'panel',
		    border: 0,
		    height: 150,
		    items: [{
			xtype: 'grid',
			height: 150,
			columns: [{
			    xtype: 'rownumberer',
			    width: 40,
			},{
			    xtype: 'checkcolumn',
			    width: 30,
			    dataIndex: 'selected',
			    editor: {
				xtype: 'checkbox',
				cls: 'x-grid-checkheader-editor'
			    }
			},{
			    text: 'Дата',
			    dataIndex: 'date',
			    width: 70,
			    renderer: Ext.util.Format.dateRenderer('d.m.Y'),
			},{
			    text: 'Клиент',
			    dataIndex: 'client',
			    width: 70,
			},{
			    text: 'Адрес',
			    dataIndex: 'address',
			    flex: 1,
			},{
			    text: 'ТТН',
			    dataIndex: 'ttn',
			    width: 50,
			},{
			    text: 'с/фактура',
			    dataIndex: 'schet',
			    width: 70,
			},{
			    text: 'Скл. код',
			    dataIndex: 'code',
			    width: 85,
			}],
			plugins: [{
			    ptype: 'cellediting',
			    clicksToEdit: 1,
			}],
			store: 'TemplateItemsStore',
		    }],
		},{
		    xtype: 'panel',
		    border: 0,
		    items: [{
			xtype: 'pagingtoolbar',
			store: 'TemplateItemsStore',
		    }],
		}],
	    },
*/	}],
    }],
    buttons: [{
	text: '< Назад',
	name: 'back',
    },{
	text: 'Далее >',
	name: 'next',
    },{
	text: 'Отмена',
	name: 'cancel',
    }],
});